// LuoTaskTray.h
#pragma once
#ifndef STDCALL
	#define STDCALL __stdcall
#endif
#ifndef INLINE
	#define INLINE	inline
#endif

/* */
#ifdef LUOTASKTRAY_EXPORTS
	#define LUOTASKTRAY_FUNC __declspec(dllexport)
#else
	#define LUOTASKTRAY_FUNC __declspec(dllimport)
#endif

/* */
extern "C" HRESULT LUOTASKTRAY_FUNC STDCALL LuoTaskTray_Activate(LPCWSTR token, void ** obj);

/* */
namespace LuoTaskTray {
const UINT WM_CREATE_TASK_TRAY = RegisterWindowMessageW(L"WM_CREATE_TASK_TRAY");
const UINT WM_TASK_TRAY_CALLBACK = RegisterWindowMessageW(L"WM_TASK_TRAY_CALLBACK");
const UINT WM_TASK_TRAY_MENU_CALLBACK = RegisterWindowMessageW(L"WM_TASK_TRAY_MENU_CALLBACK");
const UINT WM_INVOKE_SHELL_ITEM_MENU = RegisterWindowMessageW(L"WM_INVOKE_SHELL_ITEM_MENU");

enum {
	TTM_CREATED = 1000,
	TTM_CLOSED,

	TTM_EXIT,			// Menu item Exit
	
};

// UCreateParam
struct UCreateParam {
	HWND hwnd;
	UINT CallbackMessage;
};	// UCreateParam


INLINE SIZE_T InvokeShellItemMenu(HWND hwnd, ITEMIDLIST* itemId)
{
	if (hwnd != 0) {
		return (SIZE_T)PostMessageW(hwnd, WM_INVOKE_SHELL_ITEM_MENU, (WPARAM)0, (LPARAM)itemId);
	}
	return (SIZE_T)0;
}


// XTopLevelWindow
class XTopLevelWindow {
public:
	virtual void STDCALL FinalRelease() = 0;

	virtual bool STDCALL PreprocessWindowMessage(MSG* msg) = 0;
};	// XTopLevelWindow

// UActivator
class UActivator {
public:
	virtual HRESULT STDCALL Initialize() = 0;

	virtual void STDCALL Uninitialize() = 0;

	virtual HRESULT STDCALL CreateTaskTray(UCreateParam* param) = 0;
};	// UActivator

// TaskTrayUtils
class TaskTrayUtils {
public:
	virtual void AddTopLevelWindow(LuoTaskTray::XTopLevelWindow * XWnd) = 0;

	virtual void RemoveTopLevelWindow(LuoTaskTray::XTopLevelWindow * XWnd) = 0;
};	// LuoTaskTrayUtils

extern TaskTrayUtils*  g_pUtils;

/* */
extern HRESULT STDCALL Activate_import(LPCWSTR token, void ** obj);

/* */
}	// namespace LuoTaskTray
/* */
